C(ͼ-02) B
ߣ    Ķ˴Σ    Դ    ʱ䣺2007-8-28    ()


 

78. floodfill() 
ܣ floodfill()õǰͼɫһض߽ɫ(ͨǵǰͼɫ)н
÷ ú÷ʽΪvoid floodfill(int x,int y,int bordercolor);
˵ (x,y)Ϊָеĳ㣬(x,y)ڸ֮⣬ôⲿ򽫱䣬ͼӿڱ߽ơֱ߶ּϣôй©ʹСļϣҲй©Ҳ˵Ͻⱻ䡣
   bordercolorΪ߽ɫܵĻ龡溯fillpoly()floodfill()Աͽİ汾ּݡ
   graphresult()ش-7(floodڴ治)
   ˺ӦͷļΪgraphics.h
ֵ 
 floodfill() һнӰߵƷɫԲ
#include<graphics.h>
void main()
{
   int driver,mode;
   driver=DETECT;
   mode=0;
   initgraph(&driver,&mode,"");
   ellipse(188,88,0,360,100,60);
   setfillstyle(cHATCH_FILL,MAGENTA);
   floodfill(188,88,WHITE);
   getch();
   restorecrtmode();
}

79. fillpoly() κ
ܣ fillpoly()õǰͼɫͼ߿ĶΣȻõǰͼɫΡ
÷ ˺÷ʽΪvoid fillpoly(int pointnum,int *points);
˵ fillpoly()ĵʽdrawpoly()һͬúpointnumΪεĶpointsָж顣ʱĿͨsizeof()sizeof(int)Ȼõģ֮Գsizeof(int)ΪÿҪꡣ
ע⣬fillpoly()ͨյ㽫ͼηȻ䱻Χfloodfill()ͬǣfillpoly()õ䷽߽ȷϵģҿԺܼ򵥵ȷ򣬰µı߽緶Χκͼػgraphresult()ش-6(Scanڴ治)
   ӦͷļΪgraphics.h
ֵ 
úɫһΣ
#include<graphics.h>
void main()
{
   int driver,mode;  
   static int points[]={100,100,100,200,200,200,100,100};
   driver=DETECT
   mode=0;
   initgraph(&driver,mode,"");
   setfillstyle(INTERLEAVE_FILL,RED);
   fillpoly(4,points);
   getch();
   restorecrtmode();
}

80. getfillsettings() ȡú
ܣ getfillsettings()ǰͼֵ(ȼֵ)ɫֵ(ȼֵ)fillsettingstyleͽṹӶӸýṹлõǰ(ͼɫ)
÷ ÷ʽΪvoid getfillsettings(struct fillsettingstype *info);
˵ fillsettingstype ͽṹ£
   struct fillsettingstype {
         int pattern;
         int color;
   };
   ע⣬ṹбpatternֻڴȡһԤȶͼֵͼԪأͼȼֵǰ1-12Ѿгṹcolor洢ɫֵǵǰʾģʽЧɫֵ֮һ
   getfillsettings()Ӧͷļgraphics.h
ֵصǰͼɫֵװinfoָĽṹ
 ĳѵǰͼɫֵдfillinfoṹУ
   struct fillsettingstype fillinfo;
   getfillsettings(&fillinfo);

81. getfillpattern() ȡûͼú
ܣ getfillpattern()һεsetfillpattern()õûͼ
÷ ˺÷ʽΪvoid getfillpattern(char *pattern);
˵ һãͻѶ嵱ǰûͼ8ֽpatternָ飬8ֽڳûͼ88λֽڵģʽУûеsetfillpattern()ûͼôԪصֵȫΪ0xff
   getfillpattern()ӦͷļΪgraphics.h
ֵ ûͼ8ֽ(עⲻͼԪ)patternָ
 ʾɵǰûͼĸֽݣ
#include<graphics.h>
void main()
{
   int driver,mode;
   char fp[8];
   int i;
   driver=DETECT;
   mode=0;
   initgraph(&driver,&mode,"");
   getfillpattern(fp);
   for(i=0;i<8;i++) printf("%d",fp[i]);
   getch();
   restorecrtmode();
}


()ͼ
   ͼơԼһĻͼĲӦóǷǳõģԶǱزٵġBCṩ¼ͼ

82. imagesize() ͼ洢С
ܣ imagsize()ش洢һĻͼڴС(ֽ)
÷ ˺÷ʽΪunsigned imagsize(int left,int top,int right,int bottom);
˵ (left,top)ΪһͼĻϽǣ(right,bottom)Ϊ½ǡ
   ִк󣬷ش洢ÿĻҪֽҪֽ64KBô-1imagesize()һgetimage()á
   ӦͷļΪgraphics.h
ֵ һͼĻ洢ֽ64KB򷵻-1
 ȷϽ(10,10)½(100,100)Ļͼֽ
   unsigned size;
   size=imagesize(10,10,100,100);

83. getimage() ͼ
ܣ getimage()Ͻ½Ļͼεָڴ
÷ ú÷ʽΪvoid getimage(int left,int top,int right,int bottom,void *buf);
˵ в(left,top)ΪҪͼĻϽǣ(right,bottom)Ϊ½ǣbufָ򱣴ͼڴַgetimage()Ļͼ񣬿imagesize()ȷͼֽmalloc()洢ͼڴ(ڴС64KB)溯putimage()getimage()Ļͼ
   ӦͷļΪgraphics.h
ֵ 
 ѴԽߵľοĻλϣ
#include<garphics.h>
#include<stdlib.h>
#include<conio.h>
void main()
{
   int driver,mode;
   unsigned size;
   void *buf;
   driver=DETECT;
   mode=0;
   initgraph(&driver,&mode,"");
   sector(15);
   rectangle(20,20,200,200);
   setcolor(RED);
   line(20,20,200,200);
   setcolor(GREEN);
   line(20,200,200,20);
   getch();
   size=imagesize(20,20,200,200);
   if(size!=-1){
      buf=malloc(size);
      if(buf){
         getimage(20,20,200,200,buf);
         putimage(100,100,buf,COPy_PUT);
         putimage(300,50,buf,COPy_PUT);
      }
   }
   outtext("press a key");
   getch();
   restorecrtmode();
}

84. putimage() ͼ
ܣ putimage()һǰڴеͼĻϡ
÷ ˺÷ʽΪvoid putimage(int left,int top,void *buf,int ops);
˵ (left,top)ΪĻͼϽǣͼʼλábufָҪڴͼ񡣲opsͼԺַʽĻϡ1-13ͼʽ

1-13  ͼʽ
--------------------------------------------------------------------
   ʽ      ȡֵ                    
--------------------------------------------------------------------
   COPy_PUT              0         ͼĻϣȡԭͼ
   xOR_PUT               1         ͼԭ
   OR_PUT                2         ͼԭ
   AND_PUT               3         ͼԭ
   NOT_PUT               4         󷴵λͼĻ
--------------------------------------------------------------------

1) COPy_PUTʽ
   ͼÿضֱӻƵĻϣȡԭͼأհ׵ͼ()ȫհ׵ͼͼĻһ֡ͨѡxOR_PUTʽԭͼ
2)xOR_PUTʽ
   ԭĻÿӦͼֽ㣬ĻϡĳһͼĻԭͼʱĻʾͼĺϳɡͬͼ㣬ЧزͼԭʼĻʽԶǷǳõġ
3)OR_PUTʽ
   ÿͼֽںӦĻ㣬ٽĻϣʽҲСȡһסеÿλͼеÿλ㣬ýǱͼĲɫϳͼ
4)AND_PUTʽ
   ѡAND_PUTͼʽʱĻغͼֽжʾλʾ磬ͼеĿհױ˷Լɫֻͼ񸴸ŵķ£ʾͬͼ
5)NOT_PUTʽ
   NOT_PUTʽ˰ͼÿλ---ͼкڵ(0000)˰ɫ(1111)COPy_PUTͬͼػʧ
   putimage()ӦͷļΪgarphics.h
ֵ 
 ĳ˵imagesize(),getimage()putimage()ĵ÷
#include<graphics.h>
#include<conio.h>
#include<stdlib.h>
void box(int ,int,int,int,int);
void main()
{
   int driver,mode;
   unsigned size;
   void *buf;
   driver=DETECT;
   mode=0;
   initgraph(&driver,&mode,"");
   box(20,20,200,200,15);
   setcolor(RED);
   line(20,20,200,200);
   setcolor(GREEN);
   line(20,200,200,20);
   getch();
   size=imagesize(20,20,200,200);
   if(size!=-1)
   {
      buf=malloc(size);
      if(buf){
         getimage(20,20,200,200,buf);
         putimage(120,120,buf,COPy_PUT);
         putimage(280,60,buf,COPy_PUT);
      }
   }
   outtext("Press a key");
   getch();
   restorecrtmode)(;
}
void box(int startx,int starty,int endx,int endy,int color)
{
   setcolor(color);
   rectangle(startx,starty,endx,endy);
}
ͼǶĻͼ۵ģĻͼͬáʵϣĻͼҲһضĻͼɳΪĻͼĻͼͼͼβ֡ 

ãصС˵ www.27txt.com ӭȥŶ
վԴȫתԻ֧棬ȨУ